package com.briup.jz.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.jz.bean.AccountApply;
import com.briup.jz.bean.AccountCustomer;
import com.briup.jz.bean.AccountCustomerExample;
import com.briup.jz.service.IAccountCustomerService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@Api(description = "顾客账户明细")
@Validated
@RestController
@RequestMapping("/customer")
public class AccountCustomerController {
	@Autowired
	private IAccountCustomerService accountcustomerservice;
	@ApiOperation(value = "添加顾客账户")
    @ApiImplicitParams({
    	    @ApiImplicitParam(name="id",value = "主键",paramType = "form"),
            @ApiImplicitParam(name="transferMoney",value = "交易金额",paramType = "form"),
            @ApiImplicitParam(name="transferTime",value = "交易时间",paramType = "form",required = true),
            @ApiImplicitParam(name="description",value = "交易描述",paramType = "form"),
            @ApiImplicitParam(name="type",value = "类型",paramType = "form"),
            @ApiImplicitParam(name="status",value = "状态",paramType = "form"),
            @ApiImplicitParam(name="userId",value = "用户ID",paramType = "form")
    })
    @PostMapping("insert")
    public Message insert(AccountCustomer accountcustomer){
        accountcustomerservice.saveOrUpdate(accountcustomer);
        System.out.println(accountcustomer);
        return MessageUtil.success("更新成功");
    }
	@ApiOperation(value = "修改账户记录")
    @GetMapping("updateById")
    public Message updateByPrimaryKey(AccountCustomer accountcustomer){
		accountcustomerservice.saveOrUpdate(accountcustomer);
    	return MessageUtil.success("修改成功");
    }
	@ApiOperation(value = "查询账户记录")
    @GetMapping("selectAll")
    public Message selectAll(AccountCustomerExample example){
		List<AccountCustomer> list= accountcustomerservice.selectByExample(example);
		return MessageUtil.success(list);
    
    }
	 @ApiOperation(value = "通过id删除账户变动")
	    @GetMapping("deleteById")
	  
	    public Message deleteById(Long id){
		 accountcustomerservice.deleteByPrimaryKey(id);
	        return MessageUtil.success("删除成功");
	    }
	 @ApiOperation(value = "通过ID查询账户记录")
	    @GetMapping("selectById")
	    public AccountCustomer selectById(Long id){
	    	return accountcustomerservice.selectByPrimaryKey(id);
	    }
}
